package com.jingzhi.count.utils;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import org.apache.commons.codec.binary.Hex;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;
import java.util.List;

/**
 * 作者： 张恒同
 * 时间： 2018/3/28   14:32
 * 描述：
 */
public class HexDecoder extends MessageToMessageDecoder<ByteBuf> {
    private Logger logger = LoggerFactory.getLogger(HexDecoder.class);

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) throws Exception {
        byte[] receiveMsgBytes = HexUtil.readBuffer(msg);
        //out.add(HexUtil.encodeHexStr(receiveMsgBytes));
        out.add(receiveMsgBytes);
        //out.add(receiveMsgBytes);
        //String encodeStr = HexUtil.encodeHexStr(receiveMsgBytes);
        //byte[] decodeStr = HexUtil.decodeHex(encodeStr.toCharArray());
    }

}
